﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using ZHDJ.Data.Models.JoinParty;
using ZHDJ.JoinParty.BLL;
using ZHDJ.WebPage;

namespace JoinParty.admin.Control
{
    public partial class UserMessage : System.Web.UI.UserControl
    {
        /// <summary>
        /// 获取当前环节ID
        /// </summary>
        public string CurrentStandID
        {
            get
            {
                return Request.QueryString["StandID"] ?? string.Empty;
            }

        }

        public string Stype
        {
            get
            {
                return Request.QueryString["Stype"] ?? string.Empty;
            }
        }
        /// <summary>
        /// 用于确认是否由处理环节进入打开信息  在ToDoFlowList后台定义
        /// </summary>
        public string Audit
        {
            get
            {
                return Request.QueryString["Audit"] ?? string.Empty;
            }
        }
        public string CurrentStepID
        {
            get
            {
                return Request.QueryString["CurrentStepID"] ?? string.Empty;
            }
        }

        public string AppllicationID { get; set; }

        public string AppllicationIDAndLoginID
        {
            get
            {
                string result = "null,null";

                var oModel = ZHDJ.WebPage.RolePageBase.DB.PartyJoinLinkExamples.Find(this.CurrentStandID);

                if (oModel != null)
                {
                    if (!string.IsNullOrEmpty(oModel.AppllicationID))
                    {
                        var uMode = ZHDJ.WebPage.RolePageBase.DB.PartyJoinApplycation.Find(oModel.AppllicationID);
                        result = uMode.AppllicationID + "," + uMode.LoginID;
                    }

                    ///绑定url
                    if (this.Audit == "true")
                    {
                        this.hlName.OnClientClick = UserMessageEdit.GetShowReference(string.Format("../ApplyJoin/ApplyJoinPartyEdit.aspx?AppllicationID={0}&Modifly=true", oModel.AppllicationID), "详细信息", 850, 600);
                    }
                    else
                    {
                        this.hlName.OnClientClick = UserMessageEdit.GetShowReference(string.Format("../ApplyJoin/ApplyJoinPartyEdit.aspx?AppllicationID={0}&ReadOnly=1", oModel.AppllicationID), "详细信息", 850, 600);
                    }

                }
                return result;
            }

        }

        protected void Page_Load(object sender, EventArgs e)
        {
            AppllicationID = AppllicationIDAndLoginID.Split(',')[0].ToString();
            DataSet ds = ModuleUtil.GetUsetMassageByAppllicationID(AppllicationID);
            DataSet dsEx = ModuleUtil.GetUsetMassage(AppllicationIDAndLoginID.Split(',')[1].ToString());
            try
            {
                if (ds.Tables[0].Rows.Count > 0)
                {
                    lbName.Text = ds.Tables[0].Rows[0]["UserName"].ToString();
                    lWorkAddress.Text = ds.Tables[0].Rows[0]["WorkUnit"].ToString(); ;
                    //lPost.InnerText = ds.Tables[0].Rows[0]["Post"].ToString();
                    lAddress.Text = ds.Tables[0].Rows[0]["Address"].ToString();
                    var imgurl = string.Empty;
                    if (Convert.ToString(dsEx.Tables[0].Rows[0]["ImageUrl"].ToString()) != "")
                    {
                        imgurl = UpFileBusiness.GetFileUrl(dsEx.Tables[0].Rows[0]["ImageUrl"].ToString(), true);
                    }
                    else
                        imgurl = string.IsNullOrEmpty(imgurl) ? "../../../../../Resource/themes/default/images/Party/Party-Emblem.jpg" : imgurl;
                    this.imgFileFromBy.ImgUrl = imgurl;
                }
            }
            catch (Exception)
            {

                throw;
            }
            if (Stype == "y")
            { this.hlName.Visible = false; }

        }

        public string GetContent
        {
            get
            {
                var ps = ZHDJ.WebPage.ControlBusiness.DB.PartyJoinProcesss.Find(this.CurrentStepID);

                if (ps != null)
                {
                    if (string.IsNullOrEmpty(ps.WorkPoint))
                    {
                        this.trGZZY.Style.Add("display", "none");
                        this.trZYNR.Style.Add("display", "none");
                    }
                }
                return ps.WorkPoint;
            }
        }
    }
}